package com.leilingmin.www.controller;

import com.leilingmin.www.entity.FeedBack;
import com.leilingmin.www.service.FeedBackService;
import com.leilingmin.www.util.RespResult;
import com.leilingmin.www.util.ValidationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/feedback")
public class FeedBackController extends BaseController{
    @Autowired
    private FeedBackService feedBackService;

    @PostMapping("/save")
    @ResponseBody
    public RespResult save(FeedBack feedBack){

        if (!(ValidationUtils.validateEmail(feedBack.getEmail()))){
            return RespResult.fail("邮箱地址不符合！");
        }
        feedBackService.save(feedBack);
        return RespResult.success("提交反馈成功！");
    }
}
